<?php
/**
 * 发票model
 * User: guojing
 * Date: 2020/4/7
 * Time: 23:17
 */
namespace app\api\model;

use think\Model;

class Invoice extends Model
{

    protected $name = 'invoice';

    public static function selListByCondition($condition = [])
    {
        return self::where($condition)->select();
    }

    public static function findInfoByCondition($condition = [])
    {
        return self::where($condition)->find();
    }

    public static function addRecord($addData)
    {
        $addData['createtime'] = time();
        $addData['updatetime'] = time();
        return self::create($addData);
    }

    public static function saveData($id, $data)
    {
        $data['updatetime'] = time();
        return self::where(['id' => $id])->update($data);
    }

    public static function sumInvoicePrice($condition = [])
    {
        return self::where($condition)->sum('amount');
    }

}